<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title>添加内容</title>
    <link rel="stylesheet" href="__CSS__/pintuer.css">
    <link rel="stylesheet" href="__CSS__/admin.css">
    <link rel="stylesheet" href="__STATIC__/css/layui.css">
    <script src="__STATIC__/layui.js"></script>
    <script src="__JS__/jquery.js"></script>
    <script src="__JS__/pintuer.js"></script>
</head>

<body>
<div class="panel admin-panel">
    <div style="margin-bottom: 1%" class="panel-head"><strong class="icon-reorder">费用报销单详情</strong>&emsp;&emsp;<a
            style="color: #3a4bfb;font-weight: bold " href="javascript:history.go(-1)">返回上一步</a></div>
    <h3 align="center" style="margin:30px">审批记录</h3>
    <div style="width: 900px; margin: auto">
        <table width="900px" border="1" class="layui-table">
            <thead>
            <tr align="center" valign="middle">
                <td>审批级别</td>
                <td>审批角色</td>
                <td>审批人</td>
                <td>审批时间</td>
                <td>审批意见</td>
                <td>审批结果</td>
            </tr>
            </thead>
            {volist name="state" id="ro"}
            <tr align="center" valign="middle">
                <td>{$ro.first}</td>
                <td>{$ro.role}</td>
                <td>{$ro.audit_name}</td>
                <td>{$ro.audit_time}</td>
                <td>{$ro.audit_opinion}</td>
                <td>{if condition="$ro.apply_states eq 0"}{$ro.apply_state}
                    {elseif condition="$ro.apply_states eq 1"/} {$ro.apply_state}
                    {else /}{$ro.apply_state}
                    {/if}
                </td>
            </tr>
            {/volist}
        </table>
    </div>
    <div style="margin-top: 2%">
        <form class="layui-form" id="form">
            <div style="margin-top: 2%;margin-left: 1%" class="layui-form-item">
                <lable style="float: left;margin-top: 1%" class="layui-form-lable">
                    审批流程：
                </lable>
                <div style="margin-left: 8%" class="layui-input-block">
                    <input readonly="readonly" value="{$approve.flow_id}" class="layui-input" type="text">
                </div>
                <lable style="float: left;margin-top: 4%;margin-left: 2.5%" class="layui-form-lable">
                    时间：
                </lable>
                <div style="margin-top: 3%;margin-left: 1.5%" class="layui-input-inline">
                    <input type="hidden" value="1" name="bill_type_id" id="bill_type_id">
                    <input type="hidden" value="{$approve.id}" name="id" id="id">
                    <input type="text" readonly="readonly" id="reimbursement_time" lay-verify="date|required"
                           placeholder="yyyy-MM-dd"
                           name="reimbursement_time" value="{$approve.reimbursement_time}" class="layui-input">


                </div>
                <div style="margin-top: 3.7%;margin-left: 30%">
                    {if condition="$approve.bill eq null"}
                    <a href="#">未上传相关文件</a>
                    {else /}
                    <a class="layui-btn" href="{:url('Myself/download')}?filepath={$approve.bill}&id={$approve.id}">点击下载相关文件</a>
                    {/if}
                </div>


            </div>
            <h3 style="text-align: center"><b>费用报销单</b></h3>
            <table class="layui-table" lay-size="lg">
                <col width="350">
                <col width="150">
                <thead>
                <tr>
                    <th style="text-align: center">用途</th>
                    <th style="text-align: center">金额（元）</th>
                </tr>
                </thead>
                <tbody>
                {volist name="$approve.expense_reimbursement_cost" id="vo"}
                <tr>
                    <td><input readonly="readonly" value="{$vo.purpose}" name="purpose{$vo.id}" id="purpose{$vo.id}"
                               type="text" class="layui-input"></td>
                    <td><input readonly="readonly" onblur="sum()" value="{$vo.money}" lay-verify="num"
                               id="money{$vo.id}" name="money{$vo.id}" type="text"
                               class="layui-input"></td>
                </tr>
                {/volist}
                <tr>
                    <td style="text-align: center;vertical-align: middle;">合计</td>
                    <td><input readonly="readonly" value="{$approve.total}" lay-verify="num" id="total" name="total"
                               type="text" class="layui-input">
                    </td>
                </tr>
                <tr>
                    <td style="text-align: left;" colspan="2">大写金额：<input readonly="readonly" id="capital_total"
                                                                          value="{$approve.capital_total}"
                                                                          name="capital_total" type="text"
                                                                          class="layui-input">
                    </td>
                </tr>
                <tr>
                    <td style="text-align: left">原借款：<input lay-verify="num" readonly="readonly"
                                                            value="{$approve.original_borrow}" id="original_borrow"
                                                            name="original_borrow"
                                                            type="text"
                                                            class="layui-input"></td>
                    <td style="text-align: left">退/补：<input readonly="readonly" lay-verify="num"
                                                            value="{$approve.return}" id="return" name="return"
                                                            type="text"
                                                            class="layui-input"></td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>
</div>
<div class="layui-form-item layui-form-text" style="margin-top: 25px">
    <label class="layui-form-label">审批建议</label>
    <div class="layui-input-block">
        <textarea style="width:960px " id="audit_opinion" name="audit_opinion" placeholder="请输入内容" class="layui-textarea"></textarea>
    </div>
</div>
<div style="margin-top: 2%;float: right;margin-right: 15%;margin-bottom: 3%">
    <a class="layui-btn" href="{:url('Myself/expense_reimbursement_excel')}?id={$approve.id}">下载单据打印表格</a>
    <button name="shenpi" id="shenpi" class="layui-btn" value="{$approve.id}">审批</button>
    <button name="bohui" id="bohui" class="layui-btn layui-btn-danger" value="{$approve.id}">驳回</button>
    <a class="layui-btn layui-btn-normal" href="{:url('Myself/myselfapply')}">返回</a></div>


</body>
<script>
    $(document).on('click', '#shenpi', function () {
        var res = $('#shenpi').val();
        var bill_type_id = $('#bill_type_id').val();
        var audit_opinion = $('#audit_opinion').val();
        //alert(bill_type_id);
        $.ajax({
            type: "post",
            url: "{:url('Myself/apply')}",
            data: {"data": res, 'bill_type_id': bill_type_id,'audit_opinion':audit_opinion},
            dataType: "json",
            success: function (item) {
                //alert(item);
                if (item == 1) {
                    layui.use(['layer'], function () {
                        var layer = layui.layer;
                        layer.msg('申请已审批', {icon: 1});
                        window.setTimeout("window.location=\"{:url('Myself/myselfapply')}\"", 2000);
                    });
                } else if (item == 2) {
                    layui.use(['layer'], function () {
                        var layer = layui.layer;
                        layer.msg('你已经审批完成，请不要重复审批', {icon: 1});
                    });
                    setTimeout(function () {
                        //使用  setTimeout（）方法设定定时2000<a href="https://www.baidu.com/s?wd=%E6%AF%AB%E7%A7%92&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWuHn4n1DkmynYmhu9uhcd0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHf4PWmsrHRdnWckPWnkrHmkrf" target="_blank" class="baidu-highlight">毫秒</a>
                        window.location.reload();//页面刷新
                    }, 2000);
                } else if (item == 3) {
                    layui.use(['layer'], function () {
                        var layer = layui.layer;
                        layer.msg('申请已被驳回', {icon: 1});
                    });
                    setTimeout(function () {
                        //使用  setTimeout（）方法设定定时2000<a href="https://www.baidu.com/s?wd=%E6%AF%AB%E7%A7%92&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWuHn4n1DkmynYmhu9uhcd0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHf4PWmsrHRdnWckPWnkrHmkrf" target="_blank" class="baidu-highlight">毫秒</a>
                        window.location.reload();//页面刷新
                    }, 2000);
                } else {
                    layui.use(['layer'], function () {
                        var layer = layui.layer;
                        layer.msg('审批未成功', {icon: 2});
                    });
                    setTimeout(function () {
                        //使用  setTimeout（）方法设定定时2000<a href="https://www.baidu.com/s?wd=%E6%AF%AB%E7%A7%92&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWuHn4n1DkmynYmhu9uhcd0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHf4PWmsrHRdnWckPWnkrHmkrf" target="_blank" class="baidu-highlight">毫秒</a>
                        window.location.reload();//页面刷新
                    }, 2000);
                }
                /*setTimeout(function () {
                 //使用  setTimeout（）方法设定定时2000<a href="https://www.baidu.com/s?wd=%E6%AF%AB%E7%A7%92&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWuHn4n1DkmynYmhu9uhcd0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHf4PWmsrHRdnWckPWnkrHmkrf" target="_blank" class="baidu-highlight">毫秒</a>
                 window.location.reload();//页面刷新
                 }, 2000);*/
            }

        })
    });
    $(document).on('click', '#bohui', function () {
        var res = $('#bohui').val();
        var bill_type_id = $('#bill_type_id').val();
        var audit_opinion=$('#audit_opinion').val();
        layui.use(['layer'], function () {
            var layer = layui.layer;
            //询问框
            layer.confirm('你确定要驳回？', {
                btn: ['确定', '取消'] //按钮
            }, function () {
                $.ajax({
                    type: "post",
                    url: "{:url('Myself/reject')}",
                    data: {"data": res, 'bill_type_id': bill_type_id,'audit_opinion':audit_opinion},
                    dataType: "json",
                    success: function (item) {
                        //console.log(item);
                        if (item == 1) {
                            layui.use(['layer'], function () {
                                var layer = layui.layer;
                                layer.msg('申请已驳回', {icon: 1});
                            });
                        } else if (item == 2) {
                            layui.use(['layer'], function () {
                                var layer = layui.layer;
                                layer.msg('申请已驳回，请不要重复驳回', {icon: 1});
                            });
                        } else if (item == 3) {
                            layui.use(['layer'], function () {
                                var layer = layui.layer;
                                layer.msg('申请已被审批，不能驳回', {icon: 1});
                            });
                        } else {
                            layui.use(['layer'], function () {
                                var layer = layui.layer;
                                layer.msg('驳回未成功', {icon: 2});
                            });
                        }
                    }

                })
            }, function () {
                layer.msg('你取消了驳回', {icon: 1});
            });
        });
    });
    layui.use('element', function () {
        var $ = layui.jquery
            , element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块

        //触发事件
        var active = {
            tabAdd: function () {
                //新增一个Tab项
                element.tabAdd('demo', {
                    title: '新选项' + (Math.random() * 1000 | 0) //用于演示
                    , content: '内容' + (Math.random() * 1000 | 0)
                    , id: new Date().getTime() //实际使用一般是规定好的id，这里以时间戳模拟下
                })
            }

        };

        $('.site-demo-active').on('click', function () {
            var othis = $(this), type = othis.data('type');
            active[type] ? active[type].call(this, othis) : '';
        });

        //Hash地址的定位
        var layid = location.hash.replace(/^#test=/, '');
        element.tabChange('test', layid);

        element.on('tab(test)', function (elem) {
            location.hash = 'test=' + $(this).attr('lay-id');
        });

    });
</script>
<script>
    /*function sum() {
     var verity = /^\d+(\.\d+)?$/;
     var money_a = $('#money_a').val();
     var money_b = $('#money_b').val();
     var money_c = $('#money_c').val();
     var money_d = $('#money_d').val();
     var money_e = $('#money_e').val();
     if (money_a == '') {
     money_a = 0;
     } else {
     money_a = parseFloat(money_a);
     if (money_a != '') {
     if (!verity.test(money_a)) {
     layui.use(['layer'], function () {
     var layer = layui.layer;
     layer.tips('Hi，请输入数字', '#money_a');
     });
     }
     }
     }
     if (money_b == '') {
     money_b = 0;
     } else {
     money_b = parseFloat(money_b);
     if (money_b != '') {
     if (!verity.test(money_b)) {
     layui.use(['layer'], function () {
     var layer = layui.layer;
     layer.tips('Hi，请输入数字', '#money_b');
     })
     }
     }
     }
     if (money_c == '') {
     money_c = 0;
     } else {
     money_c = parseFloat(money_c);
     if (money_c != '') {
     if (!verity.test(money_c)) {
     layui.use(['layer'], function () {
     var layer = layui.layer;
     layer.tips('Hi，请输入数字', '#money_c');
     });
     }
     }
     }
     if (money_d == '') {
     money_d = 0;
     } else {
     money_d = parseFloat(money_d);
     if (money_d != '') {
     if (!verity.test(money_d)) {
     layui.use(['layer'], function () {
     var layer = layui.layer;
     layer.tips('Hi，请输入数字', '#money_d');
     });
     }
     }
     }
     if (money_e == '') {
     money_e = 0;
     } else {
     money_e = parseFloat(money_e);
     if (money_e != '') {
     if (!verity.test(money_e)) {
     layui.use(['layer'], function () {
     var layer = layui.layer;
     layer.tips('Hi，请输入数字', '#money_e');
     });
     }
     }
     }

     var sums = money_a + money_b + money_c + money_d + money_e;
     $('#total').val(sums)
     }*/
    layui.use(['form', 'layer', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , laydate = layui.laydate;

        //日期
        /* laydate.render({
         elem: '#reimbursement_time'
         });*/
        //自定义验证规则
        form.verify({
            num: [/^[0-9]+(.[0-9]{2})?$/, '金额只能为数字']

        });
        /*//监听提交
         form.on('submit(demo)', function (data) {
         /!* var arr=$('#return').val();
         var fd = new FormData();
         fd.append("return", arr);
         fd.append("sub", "submit");
         fd.append("file", document.getElementById("test3"));
         $.ajax({
         type:"post",
         url:"{:url('Apply/reimbursement_apply')}",
         data: fd,
         processData: false,
         contentType: false
         }).done(function(res){
         alert(res);
         console.log(res);
         });

         return false;*!/
         //var fd = new FormData(document.getElementById("form"));
         var datas = JSON.stringify(data.field);
         var sub = 'submit';
         $.ajax({
         type: "post",
         url: "{:url('Apply/reimbursement_apply')}",
         data: {"data": datas, 'sub': sub},
         dataType: "json",
         success: function (a) {
         //console.log(a);
         if (a > 0) {
         layer.msg('添加成功', {icon: 1});
         //layer.close(admin);
         } else {
         layer.msg('添加失败', {icon: 2});
         //layer.close(admin);
         }
         setTimeout(function () {
         //使用  setTimeout（）方法设定定时2000<a href="https://www.baidu.com/s?wd=%E6%AF%AB%E7%A7%92&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWuHn4n1DkmynYmhu9uhcd0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHf4PWmsrHRdnWckPWnkrHmkrf" target="_blank" class="baidu-highlight">毫秒</a>
         window.location.reload();//页面刷新
         }, 2000);
         }

         });
         return false;
         });*/

    });
</script>
<script>
    layui.use('upload', function () {
        var $ = layui.jquery
            , upload = layui.upload
            , layer = layui.layer;

        //拖拽上传
        upload.render({
            elem: '#test10'
            , accept: 'file'
            , url: "{:url('Apply/upload')}"
            , auto: false
            , bindAction: '#uploads'
            , done: function (res) {
                if (res.code == 0) { //上传成功
                    layer.msg('上传成功', {icon: 1})
                }
                else if (res.code == 1) { //上传成功
                    layer.msg('上传成功1', {icon: 1})
                }
            }
        });
    });
</script>
</html>